import request from '../index';


// devicemanagement
// reboot power_off reset
export async function systemOprate(type) {
    return request({
        url: '/api/system/operate',
        method: 'post',
        data:{
            type: type
        }
    });
}

// connected devices
// get list
export function getConnectedDevices() {
    return request({
        url: '/api/client/devices',
        method: 'get'
    });
}

// about
export function getAboutInfo() {
    return request({
        url:'/api/system/about',
        method: 'get'
    });
}

/**
 * @description: get current config
 * @return {*}
 */
export function getSystemConfig() {
    return request({
        url: '/api/system/config',
        method: 'get'
    });
}

/**
 * 
 * @returns 刷新系统时间
 */
export function getSystemTime() {
    return request({
        url: '/api/system/time',
        method: 'get'
    });
}

export function pingTest(type,cont){
    return request({
        url: '/api/system/ping',
        method: 'post',
        data:{type:type,content:cont}
    });
}

/**
 * 下载配置文件
 */
export function downloadBackupFile() {
    return request({
        url: '/api/system/backup',
        method: 'get',
        responseType: 'blob'
    });
}

/**
 * 上传配置文件
 */
export function uploadRestoreFile(file) {
    return request({
        url: '/api/system/restore/upload',
        method: 'post',
        data: file,
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    });
}

export function startRestore() {
    return request({
        url: '/api/system/restore',
        method: 'post'
    });
}


export function saveQuickSettings(params) {
    return request({
        url: '/api/quick/setting',
        method: 'post',
        data: params
    });
}

export function getSystemSharing() {
    return request({
        url: '/api/system/sharing',
        method: 'get'
    });
}

export function setSystemSharing(enable,type = 'usb',) {
    return request({
        url: '/api/system/sharing',
        method: 'post',
        data: {
            type: type,
            enable: enable
        }
    });
}
